|
|
|
|
|
|
|
LISTING 10.11. ADDRDAO4.TXTINITIALIZING THE LISTVIEW CONTROL WITH DATA ACCESS OBJECTS. |
|
|
|
 |
|
|
|
|
1: Public Sub Set_ListView(KeyCode As String)
2: Dim listitemadd As ListItem
3: lvListView.ListItems.Clear
4: Set MyDyn = MyDb.OpenRecordset(SELECT * FROM [Address Entry] _ WHERE _
5: [LastName] Like & KeyCode & *, dbOpenDynaset)
6: MyDyn.MoveFirst
7: Do Until MyDyn.EOF
8: Set listitemadd = lvListView.ListItems.Add(, , _
MyDyn.Fields(LastName) _
9: & , & MyDyn.Fields(FirstName), 1, 1)
10: If Not IsNull(MyDyn.Fields(City)) Then
11: listitemadd.SubItems(1) = MyDyn.Fields(City)
12: End If
13: If Not IsNull(MyDyn.Fields(State)) Then
14: listitemadd.SubItems(2) = MyDyn.Fields(State)
15: End If
16: If Not IsNull(MyDyn.Fields(HomePhone)) Then
17: listitemadd.SubItems(3) = MyDyn.Fields(HomePhone)
18: End If
19: If Not IsNull(MyDyn.Fields(EmailAddress)) Then
20: listitemadd.SubItems(4) = MyDyn.Fields(EmailAddress)
21: End If
22: listitemadd.Tag = CStr(MyDyn.Fields(0)) & ! & _
MyDyn.Fields(LastName)
23: MyDyn.MoveNext
24: Loop
25: MyDyn.Close
26: End Sub |
|
|
|
|
|
|
|
|
For this application, the only display option that makes any sense for the ListView control is Report. It's up to you what data should be displayed for each entry. However, the minimum should be what's shown in Figure 10.14. |
|
|
|
|
|
|
|
|
Figure 10.14.
The final ListView display
showing data from the address
entry table. |
|
|
|
|
|